package com.atguigu.gmall.cart.util;


import com.atguigu.gmall.model.user.UserInfo;

public class UserThreadLocalUtils {

    private final  static ThreadLocal<UserInfo> userThreadLocal = new ThreadLocal<>();

    /**
     * 设置当前线程中的用户
     * @param user
     */
    public static void setUser(UserInfo user){
        userThreadLocal.set(user);
    }

    /**
     * 获取线程中的用户
     * @return
     */
    public static UserInfo getUser( ){
        return userThreadLocal.get();
    }
}